package com.fire.control.system.support.protocol.comman;

import com.fire.control.system.converter.Converter;
import com.fire.control.system.statics.Type_Data;

/**
 * 
 * @ClassName:  ProtocolConverter   
 * @Description:协议转换器
 * @author:   chenchuang
 *
 */
public class ProtocolConverter implements Converter<RequestProtocol,ResponseProtocol>{
	/***
	 * 
	 * <p>Title: convert</p>   
	 * <p>Description: 根据请求协议转换匹配相应的返回协议</p>   
	 * @param requestProtocol
	 * @return   
	 */
	@Override
	public ResponseProtocol convert(final RequestProtocol requestProtocol) {
		String dataType = requestProtocol.getDataType();
		if(dataType == null){
			dataType = "JSON";
		}
		dataType = dataType.toUpperCase();
		ResponseProtocol response = null;
		switch (Type_Data.getDataType(dataType)) {
		
			case JSON: response = new ResponseJsonProtocol();break;

			default:response = new ResponseJsonProtocol(); break;
		}
		response.setTaskuuid(requestProtocol.getTaskuuid());
		return response;
	}
	
}
